package com.tengju.bff.interfaces.manage.star.vo;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.util.CollectionUtils;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

@Data
public class StarExamResultVO {

    @ApiModelProperty("考试结果，10：通过，20：没通过")
    private int examResult;

    @ApiModelProperty("考试分数")
    private BigDecimal examScore = BigDecimal.ZERO;

    @ApiModelProperty("错误题目")
    private List<String> errorQuestionList;

    public void addErrorQuestion(String questionCode, String questionTitle) {
        if (CollectionUtils.isEmpty(errorQuestionList)) {
            this.errorQuestionList = new ArrayList<>();
        }
        questionTitle = questionTitle.replaceAll("（","");
        questionTitle = questionTitle.replaceAll("）","");
        errorQuestionList.add(questionCode + "." + questionTitle);
    }

    public void addScore(BigDecimal score) {
        this.examScore = this.examScore.add(score);
    }
}
